package com.kingbook.services;

import com.kingbook.core.base.SupportService;
import com.kingbook.core.result.JSONResult;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.kingbook.core.auth.LoginManager.AUTH;

/**
 * @Author Bucky
 * @Date 2020-04-25 11:10:08
 * @Version 1.0
 */
@Slf4j
@Service
public class ImagesService extends SupportService {

    @Autowired
    ConfigService configService;

    @PostConstruct
    private void init() {
        setNamespace("Images");
    }

    public JSONResult getOrderImages(int oid) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("oid", oid);
        return query("queryOrder", param);
    }

    public JSONResult saveOrderImages(Map<String, Object> param, List<Map<String, ?>> paramList) {
        delete("deleteOrder", param);
        return batchInsertReturnKey("insertOrder", paramList);
    }

    public JSONResult getVehicleImages(int vid) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("vid", vid);
        return query("queryVehicle", param);
    }

    public JSONResult saveVehicleImages(Map<String, Object> param, List<Map<String, ?>> paramList) {
        delete("deleteVehicle", param);
        return batchInsertReturnKey("insertVehicle", paramList);
    }

    public JSONResult getWorkspaceImages(int wid) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("wid", wid);
        return query("queryWorkspace", param);
    }

    public JSONResult saveWorkspaceImages(Map<String, Object> param, List<Map<String, ?>> paramList) {
        delete("deleteWorkspace", param);
        return batchInsertReturnKey("insertWorkspace", paramList);
    }




}
